console.log(".........publicHeader...........");
let publicHeader = new Vue({
    //element
    el: "#publicHeaderApp",
    data: {
        bookTypes: [],
        typeId:-1,
        name:'',
        provider:'',
        author:'',
        price:0.00,
        detail:'',
        // imgsrc:'',
        storecount:0,
    },
    methods: {
        initBookTypes() {
            //局部变量,便于get方法中调用vue对象
            let _this = this;
            $.get("/booktype/all", function (data) {
                _this.bookTypes = data;
            })
        }
        ,
        clearAddForm(){
            //打开新增地址表单时,清空表单数据
            let _this = this;

            _this.typeId=-1;
            _this.name='';
            _this.provider='';
            _this.author='';
            _this.price=0.00;
            _this.detail='';
            // _this.imgsrc='';
            _this.storecount=0;
        }
        ,
        saveBook(){

            //搜集表单数据

            let _this = this;

            let params = {
                typeId:_this.typeId,
                name:_this.name,
                provider:_this.provider,
                author:_this.author,
                price:_this.price,
                detail:_this.detail,
                // imgsrc:_this.imgsrc,
                storecount:_this.storecount
            }

            console.log(params)

            //数据提交后端接口,新增地址
            $.post("/book/add",params,function (data) {
                console.log(data)

                //关闭弹窗
                $("#myModal").modal('hide')

                //刷新可选地址
                _this.initBookTypes();
            })


        }
    },
    //vue生命周期中调用
    created() {
        this.initBookTypes();
    }
});
